﻿uniform sampler2D SourceMap;
uniform float BlurRadius;

#define SAMPLES 32.0
#define SAMPLES2 16.0

inline vec3 blur(vec2 uv,float xi,float yi){

	vec3 r;

	for(int i=0;i<SAMPLES;i++){

		vec3 nv = texture2D( SourceMap,uv ).rgb;
	
	    r+=nv;

		
		uv.x+=xi;
		uv.y+=yi;
	}
	return r/(float)SAMPLES;

}


void main(){

	vec3 rgb;

	vec2 uv = gl_TexCoord[0].st;

	int a;
	float divc=0.0;

	for(a=0;a<180;a+=35){

		float ang = a;
		ang*=0.0174532925;

		float xi = cos(ang)*BlurRadius;
		float yi = sin(ang)*BlurRadius;

		vec2 nv = uv;

		nv.x-=(xi*(SAMPLES2));
		nv.y-=(yi*(SAMPLES2));

		rgb+=blur( nv,xi,yi );
		divc+=1.0;
	}

	rgb/=divc;
	

	gl_FragColor.rgb = 1.0;
	gl_FragColor.a = 1.0;

}